home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-07-30 | 1.7 KB | 69 lines |
- // Calculate application
-
- import java.io.*;
-
- public class Calculate {
-
- public Calculate () {
- }
-
- // main method that is where the execution starts
- public static void main(String args[]) throws IOException{
- Calculate cal = new Calculate();
-
- cal.Comp();
- cal.printResults();
-
- System.in.read();
- System.exit(0);
- }
-
- // generate random number and perform various calculations
- public void Comp( ){
-
- System.out.println("\nPart One: \n");
- double num1 = 90*Math.random();
- double num2 = 90*Math.random();
- System.out.println("num1 is: "+num1);
- System.out.println("num2 is: "+num2);
-
- double val = Math.max(num1,num2);
-
- System.out.println("val is: "+val);
-
- double ceilVal = Math.ceil(val);
- System.out.println("the ceiling of val is: "+ceilVal);
-
- double tanCeilVal = Math.tan(Math.PI*ceilVal/180);
- System.out.println("The tangent of "+ceilVal+" degrees is: "+tanCeilVal);
-
- }
-
- // perform bitwise calculations with A and B
- public void printResults( ){
-
- System.out.println("\nPart Two: \n");
- int A=-12, B=2, result;
-
- System.out.println("A is: "+A);
- System.out.println("B is: "+B);
-
- result = A | B;
- System.out.println("A | B is: "+result);
-
- result = A & B;
- System.out.println("A & B is: "+result);
-
- result = A << B;
- System.out.println("A << B is: "+result);
-
- result = A >> B;
- System.out.println("A >> B is: "+result);
-
- result = A >>> B;
- System.out.println("A >>> B is: "+result);
- }
- }
-
-
-